﻿using System;
using System.Collections.Generic;

namespace smp.ButterflyCakes.Models.ViewModels.Order
{
    public class ShapeBuilderView
    {
        private List<int> _activeCells = new List<int>();

        public Guid ComponentId { get; set; }
        public Guid OrderId { get; set; }

        public int Portions { get; set; }

        public string ActiveCellString { get; set; }
        public List<int> ActiveCells
        {
            get
            {
                if(string.IsNullOrEmpty(ActiveCellString))
                    return _activeCells;

                _activeCells = new List<int>();
                foreach (var item in ActiveCellString.Split(','))
                {
                    int value;
                    if (int.TryParse(item, out value))
                    {
                        _activeCells.Add(value);
                    }
                }
                return _activeCells;
            }
        }
    }
}
